﻿@model cloudscribe.Core.IdentityServerIntegration.Models.IdentityEditViewModel
@using cloudscribe.Core.IdentityServerIntegration
@inject IStringLocalizer<CloudscribeIds4Resources> sr
@{
    var i = 0;
}
@if (Model.CurrentResource != null)
{
    <div class="col-md-offset-2 col-md-10">
        <h3>@sr["Claims"] </h3>
        @{ await Html.RenderPartialAsync("AddResourceClaimPartial", Model.NewClaim);}
        @if (Model.CurrentResource.UserClaims.Count > 0)
        {
            <ul class="list-unstyled">
                @foreach (var c in Model.CurrentResource.UserClaims)
                {

                <li class="mb-1 mt-1">
                    @c
                    <button type="button" class="btn btn-danger btn-sm" data-toggle="modal" data-target="@("#confirmDeleteModal" + i)">
                        @sr["Delete"]
                    </button>
                    <form asp-controller="IdentityResource" asp-action="DeleteClaim">
                        <input asp-for="SiteId" type="hidden" />
                        <input name="ResourceName" value="@Model.CurrentResource.Name" type="hidden" />
                        <input name="ClaimName" value="@c" type="hidden" />
                        <div class="modal fade" id="@("confirmDeleteModal" + i)" tabindex="-1" role="dialog" aria-labelledby="@("confirmDeleteHeading" + i)">
                            <div class="modal-dialog modal-sm" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h4 class="modal-title" id="@("confirmDeleteHeading" + i)">@sr["Confirm Delete"]</h4>
                                        <button type="button" class="close" data-dismiss="modal" aria-label='@sr["Close"]'><span aria-hidden="true">&times;</span></button>
                                    </div>
                                    <div class="modal-body">
                                        @string.Format(sr["Are you sure you want to delete {0}?"], c)
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-primary" data-dismiss="modal">@sr["Cancel"]</button>
                                        <input type="submit" value='@sr["Delete"]' class="btn btn-danger btn-ok" />
                                    </div>
                                </div>
                            </div>
                        </div>
                    </form>
                </li>
                    {
                        i += 1;
                    }
                  }
            </ul>
        }
    </div>
}
